package com.sitech.portal.system.dao.ibatis;

import java.util.HashMap;
import java.util.List;

import com.sitech.ibnms.core.BaseIbnmsDao;
import com.sitech.ibnms.core.IPage;
import com.sitech.ibnms.core.PageForm;
import com.sitech.portal.system.dao.ISysSubSystemDao;

public class SysSubSystemDaoImpl extends BaseIbnmsDao implements ISysSubSystemDao {

	public List findSubSystemListByLoginID(String LOGIN_ID) {
            return this.query("findSubSystemListByLoginID",
                    LOGIN_ID);
    }

    public void add(HashMap map) {
            this.insert("insertForTB_SYS_SUB_SYSTEM", map);
    }

    public void update(HashMap map) {
            this.update("updateForTB_SYS_SUB_SYSTEM", map);
    }

    public void deleteForTB_SYS_SUB_SYSTEMByPK(String SYSTEM_ID) {
            this.delete("deleteForTB_SYS_SUB_SYSTEMByPK", SYSTEM_ID);
    }

    public IPage findListSubSystem(PageForm pageForm) {
            return this.findPage("findListSubSystem", pageForm);
    }

    public List findListSubSystemForTree(String ROLE_ID) {
            String mySql =
                    "select distinct s.*, decode(m.module_id, s.system_id, 'true', 'false') CHECKED\n"
                    + "  from TB_SYS_SUB_SYSTEM s\n"
                    + "  left join tb_sys_role_module m on s.system_id = m.module_id\n"
                    + "                                and m.role_id = '"+ROLE_ID.replace("'", "''") +"'\n"
                    + " where ENABLE = 1\n"
                    + " order by to_number(VIEW_ORDER)";
            return this.query("findListSubSystem", mySql);
    }

    public HashMap findObjForTB_SYS_SUB_SYSTEMByPK(String SYSTEM_ID) {
            return (HashMap) this.querySingle(
                    "findObjForTB_SYS_SUB_SYSTEMByPK", SYSTEM_ID);
    }

    /**
     * 查找用户
     * @param LOGIN_ID
     * @return 
     */
    public List findSUB_SYSTEMByLoginID(String LOGIN_ID) {
            return this.query("findSUB_SYSTEMByLoginID", LOGIN_ID);
    }
}
